
clear all
set maxvar 120000
set maxiter 100
set processors 2
set more off

global dir /Volumes/Zihao_SSD2/PatentsView

*** ============================================================================================================
*** Run main regressions.
*** Table 1-6, B1-B11, B17-B21
*** Figure 1, B1, B2
*** Zihao Li. 11/2024
*** ============================================================================================================
import delimited $dir/regdata/reg_panel.csv, clear

* Encode categorical variables
encode genderdiscrete_09_100_j, gen(genderdiscrete_09_100_j_enc)
encode assignee_id_i, gen(assignee_id_i_enc)
encode assignee_id_j, gen(assignee_id_j_enc)
encode main_cpc_subclass_i, gen(main_cpc_subclass_i_enc)
encode main_cpc_subclass_j, gen(main_cpc_subclass_j_enc)
encode main_cpc_class_i, gen(main_cpc_class_i_enc)
encode main_cpc_class_j, gen(main_cpc_class_j_enc)
encode main_cpc_section_i, gen(main_cpc_section_i_enc)
encode main_cpc_section_j, gen(main_cpc_section_j_enc)
encode assignee_country_i, gen(assignee_country_i_enc)
encode assignee_country_j, gen(assignee_country_j_enc)
tostring inventor_bin_i, replace
tostring inventor_bin_j, replace
encode inventor_bin_i, gen(inventor_bin_i_enc)
encode inventor_bin_j, gen(inventor_bin_j_enc)
drop if main_cpc_section_i=="" | main_cpc_section_j==""


*** ============================================================================================================
*** Table 1. Benchmark regression
*** Logit and LPM, gender only (no interaction), no race, 1981-2015, KPSS firms
*** ============================================================================================================

*** Logit
* Col (1)
logit omission i.allfemale_09_100_j, vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table1.doc, replace dec(4) e(r2_p) keep(i.allfemale_09_100_j) addtext(Firm i FE, No, Firm j FE, No, Year i FE, No, Main CPC Section i FE, No, Main CPC Section j FE, No, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))
margins, dydx(allfemale_09_100_j) at((mean)) // 0.0092 (0.0012)

* Col (2)
logit omission i.allfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table1.doc, append dec(4) e(r2_p) keep(i.allfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, No, Firm j FE, No, Year i FE, No, Main CPC Section i FE, No, Main CPC Section j FE, No, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))
margins, dydx(allfemale_09_100_j) at((mean)) // 0.0140 (0.0011)

* Col (3)
logit omission i.allfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag i.patent_year_i i.main_cpc_section_i_enc i.main_cpc_section_j_enc, vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table1.doc, append dec(4) e(r2_p) keep(i.allfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, No, Firm j FE, No, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))
margins, dydx(allfemale_09_100_j) at((mean)) // 0.0093 (0.0012)

* Col (4)
logit omission ib2.genderdiscrete_09_100_j_enc sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag i.patent_year_i i.main_cpc_section_i_enc i.main_cpc_section_j_enc, vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table1.doc, append dec(4) e(r2_p) keep(ib2.genderdiscrete_09_100_j_enc sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, No, Firm j FE, No, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))
margins, dydx(ib2.genderdiscrete_09_100_j_enc) at((mean)) // 0.0094 (0.0012)

*** LPM
* Col (5)
reg omission i.allfemale_09_100_j, vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table1.doc, append dec(4) keep() addtext(Firm i FE, No, Firm j FE, No, Year i FE, No, Main CPC Section i FE, No, Main CPC Section j FE, No, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (6)
reg omission i.allfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table1.doc, append dec(4) keep(i.allfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, No, Firm j FE, No, Year i FE, No, Main CPC Section i FE, No, Main CPC Section j FE, No, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (7)
reghdfe omission i.allfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table1.doc, append dec(4) keep(i.allfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))


*** ============================================================================================================
*** Table 2.
*** LPM, gender only (with interactions), no race, 1981-2015, KPSS firms
*** ============================================================================================================

* Col (1)
reghdfe omission allfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table2.doc, replace dec(4) keep(allfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (2)
reghdfe omission allfemale_09_100_i sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table2.doc, append dec(4) keep(allfemale_09_100_i sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (3)
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table2.doc, append dec(4) keep(allfemale_09_100_j sim_score allfemale_09_100_i allfemale_09_100_ji dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (4)
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if ((allfemale_09_100_j==1)|(allmale_09_100_j==1)) & ((allfemale_09_100_i==1)|(allmale_09_100_i==1)), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table2.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, Homo Gender) addstat(Mean of dependent variable, e(ymean))
// lincom -allfemale_09_100_ji - 2*allfemale_09_100_j // t=7.27

* Col (5)
reghdfe omission leadfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table2.doc, append dec(4) keep(leadfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (6)
reghdfe omission leadfemale_09_100_j leadfemale_09_100_i leadfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table2.doc, append dec(4) keep(leadfemale_09_100_j leadfemale_09_100_i leadfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (7)
reghdfe omission allfemale_09_100_j leadfemale_09_100_i allfemale_leadfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table2.doc, append dec(4) keep(allfemale_09_100_j leadfemale_09_100_i allfemale_leadfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (8)
reghdfe omission allfemale_09_100_i leadfemale_09_100_j leadfemale_allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table2.doc, append dec(4) keep(allfemale_09_100_i leadfemale_09_100_j leadfemale_allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))


*** ============================================================================================================
*** Table 3. Assignee Connection (Same Assignee)
*** LPM, gender only (with interactions), no race, 1981-2015, KPSS firms
*** ============================================================================================================
gen allfemalej_sameassignee = allfemale_09_100_j * same_assignee
gen leadfemalej_sameassignee = leadfemale_09_100_j * same_assignee
gen same_assigneelocation = same_assignee * same_assignee_location
gen allfemalej_sameassigneelocation = allfemale_09_100_j * same_assigneelocation
gen leadfemalej_sameassigneelocation = leadfemale_09_100_j * same_assigneelocation

gen allfemalei_sameassignee = allfemale_09_100_i * same_assignee
gen leadfemalei_sameassignee = leadfemale_09_100_i * same_assignee
gen allfemalei_sameassigneelocation = allfemale_09_100_i * same_assigneelocation
gen leadfemalei_sameassigneelocation = leadfemale_09_100_i * same_assigneelocation
gen allinter = allfemale_09_100_j * allfemale_09_100_i * same_assignee
gen allinter_location = allfemale_09_100_j * allfemale_09_100_i * same_assigneelocation
gen allinter_lead = leadfemale_09_100_j * leadfemale_09_100_i * same_assignee

* Col (1)
reghdfe omission allfemale_09_100_j same_assignee allfemalej_sameassignee sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table3.doc, replace dec(4) keep(allfemale_09_100_j same_assignee allfemalej_sameassignee sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (2)
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji same_assignee allfemalej_sameassignee allfemalei_sameassignee allinter sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table3.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji same_assignee allfemalej_sameassignee allfemalei_sameassignee allinter sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (3)
reghdfe omission allfemale_09_100_j same_assigneelocation allfemalej_sameassigneelocation sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table3.doc, append dec(4) keep(allfemale_09_100_j same_assigneelocation allfemalej_sameassigneelocation sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (4)
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji same_assigneelocation allfemalej_sameassigneelocation allfemalei_sameassigneelocation allinter_location sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table3.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji same_assigneelocation allfemalej_sameassigneelocation allfemalei_sameassigneelocation allinter_location sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (5)
reghdfe omission leadfemale_09_100_j same_assignee leadfemalej_sameassignee sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table3.doc, append dec(4) keep(leadfemale_09_100_j same_assignee leadfemalej_sameassignee sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (6)
reghdfe omission leadfemale_09_100_j leadfemale_09_100_i leadfemale_09_100_ji same_assignee leadfemalej_sameassignee leadfemalei_sameassignee allinter_lead sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table3.doc, append dec(4) keep(leadfemale_09_100_j leadfemale_09_100_i leadfemale_09_100_ji same_assignee leadfemalej_sameassignee leadfemalei_sameassignee allinter_lead sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))


*** ============================================================================================================
*** Table 4 (Top panel). Androgynous Names.
*** LPM, gender interactions, 1981-2015, KPSS Firms. All Sample
*** ============================================================================================================
gen allfemale_io_09_100_ji = allfemale_io_09_100_j * allfemale_09_100_i
gen allfemale_io_08_100_ji = allfemale_io_08_100_j * allfemale_09_100_i
gen allfemale_io_07_100_ji = allfemale_io_07_100_j * allfemale_09_100_i
gen allfemale_io_06_100_ji = allfemale_io_06_100_j * allfemale_09_100_i

* Col (1) p=0.9
reghdfe omission allfemale_io_09_100_j allfemale_09_100_i allfemale_io_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (node_dist_first >= 3) & (same_assignee == 0) & (inventor_bin_j_enc != 6), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table4_top.doc, replace dec(4) keep(allfemale_io_09_100_j allfemale_09_100_i allfemale_io_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, Prob90) addstat(Mean of dependent variable, e(ymean))

* Col (2) p=0.8
reghdfe omission allfemale_io_08_100_j allfemale_09_100_i allfemale_io_08_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (node_dist_first >= 3) & (same_assignee == 0) & (inventor_bin_j_enc != 6), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table4_top.doc, append dec(4) keep(allfemale_io_08_100_j allfemale_09_100_i allfemale_io_08_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, Prob80) addstat(Mean of dependent variable, e(ymean))

* Col (3) p=0.7
reghdfe omission allfemale_io_07_100_j allfemale_09_100_i allfemale_io_07_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (node_dist_first >= 3) & (same_assignee == 0) & (inventor_bin_j_enc != 6), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table4_top.doc, append dec(4) keep(allfemale_io_07_100_j allfemale_09_100_i allfemale_io_07_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, Prob70) addstat(Mean of dependent variable, e(ymean))

* Col (4) p=0.6
reghdfe omission allfemale_io_06_100_j allfemale_09_100_i allfemale_io_06_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (node_dist_first >= 3) & (same_assignee == 0) & (inventor_bin_j_enc != 6), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table4_top.doc, append dec(4) keep(allfemale_io_06_100_j allfemale_09_100_i allfemale_io_06_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, Prob60) addstat(Mean of dependent variable, e(ymean))


*** ============================================================================================================
*** Table 4 (Bottom panel). Androgynous Names. Alternative Specification
*** LPM, gender interactions, 1981-2015, KPSS Firms. All Sample
*** ============================================================================================================
replace lead_gender_prob_j =. if lead_gender_prob_j == 0
replace lead_gender_prob_j =. if lead_gender_count_j < 100
gen andro_j = 2 - 2*lead_gender_prob_j
gen leadfemale_j = 1-lead_gender_ind_j
gen leadfemale_ji = leadfemale_j * leadfemale_09_100_i
gen androj_allfemalei = andro_j * allfemale_09_100_i
gen andro_leadfemale_j = andro_j * leadfemale_j
gen andro_leadfemale_ji = andro_j * leadfemale_j * allfemale_09_100_i

* Col (1)
reghdfe omission andro_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (node_dist_all >= 3) & (same_assignee==0) & (inventor_bin_j_enc != 6) & (num_inventors_j==1), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table4_bottom.doc, replace dec(4) keep(andro_j) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (2)
reghdfe omission andro_j allfemale_09_100_i androj_allfemalei sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (node_dist_first >= 3) & (same_assignee == 0) & (inventor_bin_j_enc != 6) & (num_inventors_j==1), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table4_bottom.doc, append dec(4) keep(andro_j allfemale_09_100_i androj_allfemalei) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (3)
reghdfe omission andro_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (node_dist_all >= 3) & (same_assignee==0) & (inventor_bin_j_enc != 6), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table4_bottom.doc, append dec(4) keep(andro_j) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (4)
reghdfe omission andro_j allfemale_09_100_i androj_allfemalei sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (node_dist_first >= 3) & (same_assignee == 0) & (inventor_bin_j_enc != 6), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table4_bottom.doc, append dec(4) keep(andro_j allfemale_09_100_i androj_allfemalei) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (5)
reghdfe omission andro_j leadfemale_j andro_leadfemale_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (node_dist_first>=4) & (same_assignee == 0) & (inventor_bin_j_enc !=6) & (num_inventors_j==1), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table4_bottom.doc, append dec(4) keep(andro_j leadfemale_j andro_leadfemale_j) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (6)
reghdfe omission andro_j allfemale_09_100_i leadfemale_j andro_leadfemale_j androj_allfemalei andro_leadfemale_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (node_dist_first >= 3) & (same_assignee == 0) & (inventor_bin_j_enc != 6) & (num_inventors_j==1), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table4_bottom.doc, append dec(4) keep(andro_j allfemale_09_100_i leadfemale_j andro_leadfemale_j androj_allfemalei andro_leadfemale_ji) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))


*** ============================================================================================================
*** Table 5: Omission and future productivity
*** ============================================================================================================
preserve

import delimited $dir/cleandata/inventor_cum_omission.csv, clear
merge 1:1 inventor_id year using $dir/temp/g_inventor_gender_race_age_short.dta
drop if _merge == 2
drop _merge
sort inventor_id year
format %30s inventor_id
replace num_patents = 0 if num_patents == .
replace avg_dollar_real_log = 0 if avg_dollar_real_log == .

* Gender, Race, CPC
by inventor_id: carryforward gender_09_100 race80 rep*, replace
encode gender_09_100, gen(gender_enc)
encode rep_cpcsubclass, gen(rep_cpcsubclass_enc)
drop if gender_09_100 == ""
gen female = 1 if gender_09_100 == "female"
replace female = 0 if female != 1
gen minority = 1 if race80 == "asian" | race80 == "hispanic" | race80 == "nh_black"
replace minority = 0 if minority != 1

* Number and quality of previous patents
sort inventor_id year
by inventor_id: gen cum_patents_prev = sum(num_patents) - num_patents
gen weightedsum_dollar = avg_dollar_real_log * num_patents
by inventor_id: gen cum_weightedsum_dollar_prev = sum(weightedsum_dollar) - num_patents*avg_dollar_real_log
gen cum_avg_dollar_real_log_prev = cum_weightedsum_dollar_prev / cum_patents_prev
drop if avg_dollar_real_log == .

* Number of patents in the next three/five years
gsort inventor_id -year
gen patents_next5yrs = .
by inventor_id: replace patents_next5yrs = num_patents[_n-1] + num_patents[_n-2] + num_patents[_n-3] + num_patents[_n-4] + num_patents[_n-5]
sort inventor_id year

* Indicator of publishing patents in the next three/five years
gen indicator_next5yrs = (patents_next5yrs > 0)
replace indicator_next5yrs = . if patents_next5yrs == .
gen cumsum_omission_asinh = asinh(cumsum_omission)
gen cumsum_omission_log1 = log(cumsum_omission + 1)
gen inter_gender_asinh = female * cumsum_omission_asinh
gen inter_gender_log1 = female * cumsum_omission_log1

* Merge with centrality measure
merge 1:1 inventor_id year using $dir/temp/centrality_sum_1981_2015.dta
drop if _merge==2
drop _merge
drop if omission<0 | rep_cpcsubclass_enc==.


*** Run regression
* Indicator of patenting
* Col (1)
reghdfe indicator_next5yrs cumsum_omission_asinh female cum_patents_prev cum_avg_dollar_real_log_prev, absorb(year) vce(robust)
estadd ysumm
outreg2 using $dir/reg_results/table5.doc, replace dec(4) addtext(Year FE, Yes, Inventor Field FE, No) addstat(Mean of dependent variable, e(ymean))
* Col (2)
reghdfe indicator_next5yrs cumsum_omission_asinh female inter_gender_asinh cum_patents_prev cum_avg_dollar_real_log_prev, absorb(year) vce(robust)
estadd ysumm
outreg2 using $dir/reg_results/table5.doc, append dec(4) addtext(Year FE, Yes, Inventor Field FE, No) addstat(Mean of dependent variable, e(ymean))
* Col (3)
reghdfe indicator_next5yrs cumsum_omission_asinh female inter_gender_asinh cum_patents_prev cum_avg_dollar_real_log_prev, absorb(rep_cpcsubclass_enc year) vce(robust)
estadd ysumm
outreg2 using $dir/reg_results/table5.doc, append dec(4) addtext(Year FE, Yes, Inventor Field FE, Yes) addstat(Mean of dependent variable, e(ymean))
* Col (4)
reghdfe indicator_next5yrs cumsum_omission_asinh female inter_gender_asinh cum_patents_prev cum_avg_dollar_real_log_prev log_deg_centrality, absorb(rep_cpcsubclass_enc year) vce(robust)
estadd ysumm
outreg2 using $dir/reg_results/table5.doc, append dec(4) addtext(Year FE, Yes, Inventor Field FE, Yes) addstat(Mean of dependent variable, e(ymean))


* Number of patents
* Col (5)
reghdfe patents_next5yrs cumsum_omission_asinh female cum_patents_prev cum_avg_dollar_real_log_prev, absorb(year) vce(robust)
estadd ysumm
outreg2 using $dir/reg_results/table5.doc, append dec(4) addtext(Year FE, Yes, Inventor Field FE, No) addstat(Mean of dependent variable, e(ymean))
* Col (6)
reghdfe patents_next5yrs cumsum_omission_asinh female inter_gender_asinh cum_patents_prev cum_avg_dollar_real_log_prev, absorb(year) vce(robust)
estadd ysumm
outreg2 using $dir/reg_results/table5.doc, append dec(4) addtext(Year FE, Yes, Inventor Field FE, No) addstat(Mean of dependent variable, e(ymean))
* Col (7)
reghdfe patents_next5yrs cumsum_omission_asinh female inter_gender_asinh cum_patents_prev cum_avg_dollar_real_log_prev, absorb(rep_cpcsubclass_enc year) vce(robust)
estadd ysumm
outreg2 using $dir/reg_results/table5.doc, append dec(4) addtext(Year FE, Yes, Inventor Field FE, Yes) addstat(Mean of dependent variable, e(ymean))
* Col (8)
reghdfe patents_next5yrs cumsum_omission_asinh female inter_gender_asinh cum_patents_prev cum_avg_dollar_real_log_prev log_deg_centrality, absorb(rep_cpcsubclass_enc year) vce(robust)
estadd ysumm
outreg2 using $dir/reg_results/table5.doc, append dec(4) addtext(Year FE, Yes, Inventor Field FE, Yes) addstat(Mean of dependent variable, e(ymean))


*** ============================================================================================================
*** Table B21. Robustness: log(1+x)
*** ============================================================================================================
* Probability of patenting
* Col (1)
reghdfe indicator_next5yrs cumsum_omission_log1 female cum_patents_prev cum_avg_dollar_real_log_prev, absorb(year) vce(robust)
estadd ysumm
outreg2 using $dir/reg_results/tableb21.doc, replace dec(4) addtext(Year FE, Yes, Inventor Field FE, No) addstat(Mean of dependent variable, e(ymean))
* Col (2)
reghdfe indicator_next5yrs cumsum_omission_log1 female inter_gender_asinh cum_patents_prev cum_avg_dollar_real_log_prev, absorb(year) vce(robust)
estadd ysumm
outreg2 using $dir/reg_results/tableb21.doc, append dec(4) addtext(Year FE, Yes, Inventor Field FE, No) addstat(Mean of dependent variable, e(ymean))
* Col (3)
reghdfe indicator_next5yrs cumsum_omission_log1 female inter_gender_asinh cum_patents_prev cum_avg_dollar_real_log_prev, absorb(rep_cpcsubclass_enc year) vce(robust)
estadd ysumm
outreg2 using $dir/reg_results/tableb21.doc, append dec(4) addtext(Year FE, Yes, Inventor Field FE, Yes) addstat(Mean of dependent variable, e(ymean))
* Col (4)
reghdfe indicator_next5yrs cumsum_omission_log1 female inter_gender_asinh cum_patents_prev cum_avg_dollar_real_log_prev log_deg_centrality, absorb(rep_cpcsubclass_enc year) vce(robust)
estadd ysumm
outreg2 using $dir/reg_results/tableb21.doc, append dec(4) addtext(Year FE, Yes, Inventor Field FE, Yes) addstat(Mean of dependent variable, e(ymean))

* Number of patents
* Col (5)
reghdfe patents_next5yrs cumsum_omission_log1 female cum_patents_prev cum_avg_dollar_real_log_prev, absorb(year) vce(robust)
estadd ysumm
outreg2 using $dir/reg_results/tableb21.doc, append dec(4) addtext(Year FE, Yes, Inventor Field FE, No) addstat(Mean of dependent variable, e(ymean))
* Col (6)
reghdfe patents_next5yrs cumsum_omission_log1 female inter_gender_asinh cum_patents_prev cum_avg_dollar_real_log_prev, absorb(year) vce(robust)
estadd ysumm
outreg2 using $dir/reg_results/tableb21.doc, append dec(4) addtext(Year FE, Yes, Inventor Field FE, No) addstat(Mean of dependent variable, e(ymean))
* Col (7)
reghdfe patents_next5yrs cumsum_omission_log1 female inter_gender_asinh cum_patents_prev cum_avg_dollar_real_log_prev, absorb(rep_cpcsubclass_enc year) vce(robust)
estadd ysumm
outreg2 using $dir/reg_results/tableb21.doc, append dec(4) addtext(Year FE, Yes, Inventor Field FE, Yes) addstat(Mean of dependent variable, e(ymean))
* Col (8)
reghdfe patents_next5yrs cumsum_omission_log1 female inter_gender_asinh cum_patents_prev cum_avg_dollar_real_log_prev log_deg_centrality, absorb(rep_cpcsubclass_enc year) vce(robust)
estadd ysumm
outreg2 using $dir/reg_results/tableb21.doc, append dec(4) addtext(Year FE, Yes, Inventor Field FE, Yes) addstat(Mean of dependent variable, e(ymean))

restore



*** ============================================================================================================
*** Table 6. Patent Examiners
*** LPM, gender only (with interactions), no race, 1981-2015, KPSS firms
*** ============================================================================================================
* Col (1)
reghdfe omission_examiner allfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (patent_year_i >= 2002), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table6.doc, replace dec(4) keep(allfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, Post2002) addstat(Mean of dependent variable, e(ymean)) 

* Col (2)
reghdfe omission_examiner efemale_09_100 sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (patent_year_i >= 2002), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table6.doc, append dec(4) keep(efemale_09_100 sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, Post2002) addstat(Mean of dependent variable, e(ymean))

* Col (3)
reghdfe omission_examiner allfemale_09_100_j efemale_09_100 efemale_allfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (patent_year_i >= 2002), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table6.doc, append dec(4) keep(efemale_09_100 allfemale_09_100_j efemale_allfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, Post2002) addstat(Mean of dependent variable, e(ymean))

* Col (4)
reghdfe omission_examiner allfemale_09_100_j efemale_09_100 allfemale_09_100_i efemale_allfemale_09_100_i sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (patent_year_i >= 2002), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table6.doc, append dec(4) keep(allfemale_09_100_j efemale_09_100 allfemale_09_100_i efemale_allfemale_09_100_i sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, Post2002) addstat(Mean of dependent variable, e(ymean))

* Col (5)
reghdfe omission_examiner allfemale_09_100_j efemale_09_100 allfemale_09_100_i sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (patent_year_i >= 2002), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table6.doc, append dec(4) keep(allfemale_09_100_j efemale_09_100 allfemale_09_100_i sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, Post2002) addstat(Mean of dependent variable, e(ymean))

* Col (6)
reghdfe omission_examiner leadfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (patent_year_i >= 2002), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table6.doc, append dec(4) keep(leadfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, Post2002) addstat(Mean of dependent variable, e(ymean))

* Col (7)
reghdfe omission_examiner leadfemale_09_100_j efemale_09_100 efemale_leadfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (patent_year_i >= 2002), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/table6.doc, append dec(4) keep(leadfemale_09_100_j efemale_09_100 efemale_leadfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, Post2002) addstat(Mean of dependent variable, e(ymean))








*** ============================================================================================================
*** Below are Appendix Tables
*** ============================================================================================================



*** ============================================================================================================
*** Table B1. Heterogeneity: Time Period
*** LPM, gender only (with interactions), no race, 1981-2015, KPSS firms
*** ============================================================================================================
* Col (1) 1981-1990
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (patent_year_i>=1981 & patent_year_i<=1990), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb1.doc, replace dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing) addstat(Mean of dependent variable, e(ymean))

* Col (2) 1991-2000
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (patent_year_i>=1991 & patent_year_i<=2000), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb1.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing) addstat(Mean of dependent variable, e(ymean))

* Col (3) 2001-2010
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (patent_year_i>=2001 & patent_year_i<=2010), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb1.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing) addstat(Mean of dependent variable, e(ymean))

* Col (4) 2011-2015
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (patent_year_i>=2011), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb1.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing) addstat(Mean of dependent variable, e(ymean))


*** ============================================================================================================
*** Table B2. Heterogeneity: Firm tier
*** LPM, gender only (with interactions), no race, 1981-2015, KPSS firms
*** ============================================================================================================
* Col (1) 1-10 Citing
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (assignee_rank_i <= 10), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb2.doc, replace dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Firm Citing, 1-10) addstat(Mean of dependent variable, e(ymean))

* Col (2) 10-50 Citing
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (assignee_rank_i > 10 & assignee_rank_i <= 50), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb2.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Firm Citing, 10-50) addstat(Mean of dependent variable, e(ymean))

* Col (3) 50-200 Citing
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (assignee_rank_i > 50 & assignee_rank_i <= 200), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb2.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Firm Citing, 50-200) addstat(Mean of dependent variable, e(ymean))

* Col (4) 200+ Citing
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (assignee_rank_i > 200), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb2.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Firm Citing, 200 plus) addstat(Mean of dependent variable, e(ymean))

* Col (5) 1-10 Cited
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (assignee_rank_j <= 10), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb2.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Firm Cited, 1-10) addstat(Mean of dependent variable, e(ymean))

* Col (6) 10-50 Cited
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (assignee_rank_j > 10 & assignee_rank_j <= 50), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb2.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Firm Cited, 10-50) addstat(Mean of dependent variable, e(ymean))

* Col (7) 50-300 Cited
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (assignee_rank_j > 50 & assignee_rank_j <= 200), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb2.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Firm Cited, 50-200) addstat(Mean of dependent variable, e(ymean))

* Col (8) 200+ Cited
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (assignee_rank_j > 200), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb2.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Firm Cited, 200 plus) addstat(Mean of dependent variable, e(ymean))


*** ============================================================================================================
*** Table B3. Heterogeneity: Firm tier (Alternative Tier Definition)
*** LPM, gender only (with interactions), no race, 1980-2015, KPSS firms
*** ============================================================================================================
* Col (1) 1-20 Citing
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (assignee_rank_i <= 20), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb3.doc, replace dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Firm Citing, 1-20) addstat(Mean of dependent variable, e(ymean))

* Col (2) 20-300 Citing
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (assignee_rank_i > 20 & assignee_rank_i <= 300), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb3.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Firm Citing, 20-300) addstat(Mean of dependent variable, e(ymean))

* Col (3) 300+ Citing
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (assignee_rank_i > 300), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb3.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Firm Citing, 300+) addstat(Mean of dependent variable, e(ymean))

* Col (4) 1-20 Cited
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (assignee_rank_j <= 20), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb3.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Firm Cited, 1-20) addstat(Mean of dependent variable, e(ymean))


* Col (5) 20-300 Cited
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (assignee_rank_j > 20 & assignee_rank_j <= 300), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb3.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Firm Cited, 20-300) addstat(Mean of dependent variable, e(ymean))

* Col (6) 300+ Cited
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (assignee_rank_j > 300), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb3.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Firm Cited, 300+) addstat(Mean of dependent variable, e(ymean))


*** ============================================================================================================
*** Table B4. Heterogeneity: Patent Field (Main CPC Section i)
*** LPM, gender only (with interactions), no race, 1981-2015, KPSS firms
*** ============================================================================================================
* Col (1). A: Human Necessities
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (main_cpc_section_i == "A"), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb4.doc, replace dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing) addstat(Mean of dependent variable, e(ymean))

* Col (2). B: Performing Operations; Transporting
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (main_cpc_section_i == "B"), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb4.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing) addstat(Mean of dependent variable, e(ymean))

* Col (3). C: Chemistry; Metallurgy
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (main_cpc_section_i == "C"), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb4.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing) addstat(Mean of dependent variable, e(ymean))

* Col (4). D: Textiles; Paper
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (main_cpc_section_i == "D"), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb4.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing) addstat(Mean of dependent variable, e(ymean))

* Col (5). E: Fixed Constructions
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (main_cpc_section_i == "E"), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb4.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing) addstat(Mean of dependent variable, e(ymean))

* Col (6). F: Mechanical Engineering; Lighting; Heating; Weapons; Blasting
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (main_cpc_section_i == "F"), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb4.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing) addstat(Mean of dependent variable, e(ymean))

* Col (7). G: Physics
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (main_cpc_section_i == "G"), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb4.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing) addstat(Mean of dependent variable, e(ymean))

* Col (8). H: Electricity
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (main_cpc_section_i == "H"), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb4.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing) addstat(Mean of dependent variable, e(ymean))


*** ============================================================================================================
*** Table B5. Heterogeneity: Patent Field (Main CPC Section j. i.e. by CITED patents)
*** LPM, gender only (with interactions), no race, 1980-2015, KPSS firms
*** ============================================================================================================
* Col (1). A: Human Necessities
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (main_cpc_section_j == "A"), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb5.doc, replace dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Cluster SE, Citing) addstat(Mean of dependent variable, e(ymean))

* Col (2). B: Performing Operations; Transporting
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (main_cpc_section_j == "B"), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb5.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Cluster SE, Citing) addstat(Mean of dependent variable, e(ymean))

* Col (3). C: Chemistry; Metallurgy
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (main_cpc_section_j == "C"), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb5.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Cluster SE, Citing) addstat(Mean of dependent variable, e(ymean))

* Col (4). D: Textiles; Paper
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (main_cpc_section_j == "D"), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb5.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Cluster SE, Citing) addstat(Mean of dependent variable, e(ymean))

* Col (5). E: Fixed Constructions
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (main_cpc_section_j == "E"), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb5.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Cluster SE, Citing) addstat(Mean of dependent variable, e(ymean))

* Col (6). F: Mechanical Engineering; Lighting; Heating; Weapons; Blasting
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (main_cpc_section_j == "F"), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb5.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Cluster SE, Citing) addstat(Mean of dependent variable, e(ymean))

* Col (7). G: Physics
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (main_cpc_section_j == "G"), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb5.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Cluster SE, Citing) addstat(Mean of dependent variable, e(ymean))

* Col (8). H: Electricity
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if (main_cpc_section_j == "H"), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb5.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Cluster SE, Citing) addstat(Mean of dependent variable, e(ymean))


*** ================================================================================================================
*** Table B6. Race and Ethnicity.
*** LPM, gender interactions + exist_minority_j/i (both binary variable), 1981-2015, KPSS Firms, US only.
*** ================================================================================================================
preserve
keep if assignee_country_i == "US" & assignee_country_j == "US"

* Col (1)
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji exist_minority80_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb6.doc, replace dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji exist_minority80_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, Only US) addstat(Mean of dependent variable, e(ymean))

* Col (2)
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji exist_minority80_i sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb6.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji exist_minority80_i sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, Only US) addstat(Mean of dependent variable, e(ymean))

* Col (3)
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji exist_minority80_j exist_minority80_i exist_minority80_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb6.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji exist_minority80_j exist_minority80_i exist_minority80_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, Only US) addstat(Mean of dependent variable, e(ymean))

* Col (4)
gen allblack_ji = allblack_80_j * allblack_80_i
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji allblack_80_j allblack_80_i allblack_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc years_lag if ((allblack_80_j==1 | allwhite_80_j==1) & (allblack_80_i==1 | allwhite_80_i==1)), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb6.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji allblack_80_j allblack_80_i allblack_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, Only US) addstat(Mean of dependent variable, e(ymean))

* Col (5)
gen allasian_ji = allasian_80_j * allasian_80_i
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji allasian_80_j allasian_80_i allasian_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc years_lag if ((allasian_80_j==1 | allwhite_80_j==1) & (allasian_80_i==1 | allwhite_80_i==1)), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb6.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji allasian_80_j allasian_80_i allasian_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, Only US) addstat(Mean of dependent variable, e(ymean))

* Col (6)
gen allhispanic_ji = allhispanic_80_j * allhispanic_80_i
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji allhispanic_80_j allhispanic_80_i allhispanic_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc years_lag if ((allhispanic_80_j==1 | allwhite_80_j==1) & (allhispanic_80_i==1 | allwhite_80_i==1)), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb6.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji allhispanic_80_j allhispanic_80_i allhispanic_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, Only US) addstat(Mean of dependent variable, e(ymean))

restore


*** ================================================================================================================
*** Table B7. Nationality/Country of Assignee.
*** LPM, gender interactions + nationality (both binary variable), 1980-2015, KPSS Firms.
*** Countries with highest patent counts: US, 
*** ================================================================================================================
gen us_j = assignee_country_j=="US"
gen us_i = assignee_country_i=="US"

* Col (1). Japan
gen jp_j = assignee_country_j=="JP"
gen jp_i = assignee_country_i=="JP"
gen jp_ji = jp_j * jp_i
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji jp_j jp_i jp_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc years_lag if ((jp_j==1 | us_j==1) & (jp_i==1 | us_i==1)), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb7.doc, replace dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji jp_j jp_i jp_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Country, Japan) addstat(Mean of dependent variable, e(ymean))

* Col (2). Germany
gen de_j = assignee_country_j=="DE"
gen de_i = assignee_country_i=="DE"
gen de_ji = de_j * de_i
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji de_j de_i de_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc years_lag if ((de_j==1 | us_j==1) & (de_i==1 | us_i==1)), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb7.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji de_j de_i de_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Country, Germany) addstat(Mean of dependent variable, e(ymean))

* Col (3). Korea
gen kr_j = assignee_country_j=="KR"
gen kr_i = assignee_country_i=="KR"
gen kr_ji = kr_j * kr_i
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji kr_j kr_i kr_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc years_lag if ((kr_j==1 | us_j==1) & (kr_i==1 | us_i==1)), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb7.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji kr_j kr_i kr_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Country, Korea) addstat(Mean of dependent variable, e(ymean))


*** ============================================================================================================
*** Table B8. Benchmark regression showing all control variables. See output of Table 1 above.
*** Table B9. Gender interaction effects showing all control variables. See output of Table 2 above.
*** ============================================================================================================


*** ============================================================================================================
*** Table B10. Benchmark regression (Robustness: Additional controls variables)
*** I split it into two due to formatting:
*** B3a: First two columns (propensity score matching). B3b: Other columns
*** LPM, gender only (no interaction), no race, 1980-2015, KPSS firms
*** ============================================================================================================
* Col (1): Propensity score matching (on cosine similarity)
psmatch2 allfemale_09_100_j sim_score, out(omission)
matrix A = (r(att) \ r(seatt))
esttab matrix(A) using $dir/reg_results/tableb10a.doc, replace

* Col (2): Propensity score matching (on other variables)
psmatch2 allfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc, out(omission)
matrix A = (r(att) \ r(seatt))
esttab matrix(A) using $dir/reg_results/tableb10a.doc, append


* Col (3) CPC Subclass fixed-effects for both i,j
reghdfe omission allfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_subclass_i_enc main_cpc_subclass_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb10.doc, replace dec(4) keep(allfemale_09_100_j sim_score dollar_real_log_j) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Subclass i FE, Yes, Main CPC Subclass j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (4): Similarity squared
gen sim_score_sq = sim_score^2
reghdfe omission allfemale_09_100_j sim_score dollar_real_log_j sim_score_sq num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb10.doc, append dec(4) keep(allfemale_09_100_j sim_score dollar_real_log_j sim_score_sq) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (5): Same assignee geographical location
reghdfe omission allfemale_09_100_j sim_score dollar_real_log_j sim_score_sq same_assignee_location num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb10.doc, append dec(4) keep(allfemale_09_100_j sim_score dollar_real_log_j sim_score_sq same_assignee_location) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (6): All-Female patent share in CPC Subclass j
reghdfe omission allfemale_09_100_j sim_score dollar_real_log_j sim_score_sq same_assignee_location fshare_cpcsubclass_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb10.doc, append dec(4) keep(allfemale_09_100_j sim_score dollar_real_log_j sim_score_sq same_assignee_location fshare_cpcsubclass_j) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (7): Lead-Female patent share in CPC Subclass j
reghdfe omission allfemale_09_100_j sim_score dollar_real_log_j sim_score_sq same_assignee_location fshare_cpcsubclass_j flshare_cpcsubclass_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb10.doc, append dec(4) keep(allfemale_09_100_j sim_score dollar_real_log_j sim_score_sq same_assignee_location fshare_cpcsubclass_j flshare_cpcsubclass_j) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (8): Female inventor share in CPC Subclass j
reghdfe omission allfemale_09_100_j sim_score dollar_real_log_j sim_score_sq same_assignee_location fshare_cpcsubclass_j flshare_cpcsubclass_j finvshare_cpcsubclass_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb10.doc, append dec(4) keep(allfemale_09_100_j sim_score dollar_real_log_j sim_score_sq same_assignee_location fshare_cpcsubclass_j flshare_cpcsubclass_j finvshare_cpcsubclass_j) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (9): Gender of Patent Attorney
reghdfe omission allfemale_09_100_j sim_score dollar_real_log_j sim_score_sq same_assignee_location fshare_cpcsubclass_j flshare_cpcsubclass_j finvshare_cpcsubclass_j a_existfemale_09_100 num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb10.doc, append dec(4) keep(allfemale_09_100_j sim_score dollar_real_log_j sim_score_sq same_assignee_location fshare_cpcsubclass_j flshare_cpcsubclass_j finvshare_cpcsubclass_j a_existfemale_09_100) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, Attorneys) addstat(Mean of dependent variable, e(ymean))
drop sim_score_sq


*** ============================================================================================================
*** Table B11. Validation of textual similarity (among top 5 patents)
*** Regress textual similarity on other objective measures of patent distance (patent class/family)
*** LPM, gender interactions, 1980-2015, KPSS Firms. All Sample
*** ============================================================================================================
* Col (1)
reg same_main_cpc sim_score, vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb11.doc, replace dec(4) keep() addtext(Firm i FE, No, Firm j FE, No, Year i FE, No, Main CPC Section i FE, No, Main CPC Section j FE, No, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (2)
reg same_main_cpc sim_score allfemale_09_100_j, vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb11.doc, append dec(4) keep() addtext(Firm i FE, No, Firm j FE, No, Year i FE, No, Main CPC Section i FE, No, Main CPC Section j FE, No, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (3)
reg same_main_cpc sim_score allfemale_09_100_j dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_assignee_country years_lag, vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb11.doc, append dec(4) keep(allfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_assignee_country years_lag) addtext(Firm i FE, No, Firm j FE, No, Year i FE, No, Main CPC Section i FE, No, Main CPC Section j FE, No, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (4)
reghdfe same_main_cpc sim_score allfemale_09_100_j dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb11.doc, append dec(4) keep(sim_score allfemale_09_100_j dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, YES, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

preserve

merge m:1 patent_id_i using $dir/temp/patent_family_i.dta
drop if _merge!=3
drop _merge
merge m:1 patent_id_j using $dir/temp/patent_family_j.dta
drop if _merge!=3
drop _merge
gen same_family_id = (family_id_extended_i == family_id_extended_j)

* Col (5)
reg same_family_id sim_score, vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb11.doc, append dec(4) keep() addtext(Firm i FE, No, Firm j FE, No, Year i FE, No, Main CPC Section i FE, No, Main CPC Section j FE, No, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (6)
reg same_family_id sim_score allfemale_09_100_j, vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb11.doc, append dec(4) keep() addtext(Firm i FE, No, Firm j FE, No, Year i FE, No, Main CPC Section i FE, No, Main CPC Section j FE, No, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (7)
reg same_family_id sim_score allfemale_09_100_j dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_assignee_country years_lag, vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb11.doc, append dec(4) keep(allfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_assignee_country years_lag) addtext(Firm i FE, No, Firm j FE, No, Year i FE, No, Main CPC Section i FE, No, Main CPC Section j FE, No, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (8)
reghdfe same_family_id sim_score allfemale_09_100_j dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb11.doc, append dec(4) keep(sim_score allfemale_09_100_j dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, YES, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

restore


*** ============================================================================================================
*** Table B12. Validation of textual similarity (5 random patents).
*** See run_reg_randsample.do
*** ============================================================================================================


*** ============================================================================================================
*** Table B13. Robustness: impose cutoff based on underlying cosine similarity.
*** See run_reg_cutoff.do
*** ============================================================================================================


*** ============================================================================================================
*** Table B14. Different values of fixed k. 
*** Table B15. Flexible k.
*** Table B16. Restrict to KPSS firms before generating the omission index.
*** See run_reg_robustk.do
*** ============================================================================================================



*** ============================================================================================================
*** Table B17. Patent Attorneys
*** LPM, gender only (with interactions), no race, 1980-2015, KPSS firms
*** ============================================================================================================
* Col (1)
reghdfe omission allfemale_09_100_j sim_score dollar_real_log_j a_existfemale_09_100 num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb17.doc, replace dec(4) keep(allfemale_09_100_j sim_score dollar_real_log_j a_existfemale_09_100 num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (2)
reghdfe omission allfemale_09_100_i sim_score dollar_real_log_j a_existfemale_09_100 num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb17.doc, append dec(4) keep(allfemale_09_100_i sim_score dollar_real_log_j a_existfemale_09_100 num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (3)
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j a_existfemale_09_100 num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb17.doc, append dec(4) keep(allfemale_09_100_j sim_score allfemale_09_100_i allfemale_09_100_ji dollar_real_log_j a_existfemale_09_100 num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (4)
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j a_existfemale_09_100 num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if ((allfemale_09_100_j==1)|(allmale_09_100_j==1)) & ((allfemale_09_100_i==1)|(allmale_09_100_i==1)), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb17.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j a_existfemale_09_100 num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, Homo Gender) addstat(Mean of dependent variable, e(ymean))

* Col (5)
reghdfe omission leadfemale_09_100_j sim_score dollar_real_log_j a_existfemale_09_100 num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb17.doc, append dec(4) keep(leadfemale_09_100_j sim_score dollar_real_log_j a_existfemale_09_100 num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (6)
reghdfe omission leadfemale_09_100_j leadfemale_09_100_i leadfemale_09_100_ji sim_score dollar_real_log_j a_existfemale_09_100 num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb17.doc, append dec(4) keep(leadfemale_09_100_j leadfemale_09_100_i leadfemale_09_100_ji sim_score dollar_real_log_j a_existfemale_09_100 num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (7)
reghdfe omission allfemale_09_100_j leadfemale_09_100_i allfemale_leadfemale_09_100_ji sim_score dollar_real_log_j a_existfemale_09_100 num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb17.doc, append dec(4) keep(allfemale_09_100_j leadfemale_09_100_i allfemale_leadfemale_09_100_ji sim_score dollar_real_log_j a_existfemale_09_100 num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (8)
reghdfe omission allfemale_09_100_i leadfemale_09_100_j leadfemale_allfemale_09_100_ji sim_score dollar_real_log_j a_existfemale_09_100 num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb17.doc, append dec(4) keep(allfemale_09_100_i leadfemale_09_100_j leadfemale_allfemale_09_100_ji sim_score dollar_real_log_j a_existfemale_09_100 num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))



*** ============================================================================================================
*** Table B18. Table 2, cluster at CITED patent (patent_id_j)
*** LPM, gender only (with interactions), no race, 1980-2015, KPSS firms
*** ============================================================================================================

* Col (1)
reghdfe omission allfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_j)
estadd ysumm
outreg2 using $dir/reg_results/tableb18.doc, replace dec(4) keep(allfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Cited, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (2)
reghdfe omission allfemale_09_100_i sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_j)
estadd ysumm
outreg2 using $dir/reg_results/tableb18.doc, append dec(4) keep(allfemale_09_100_i sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Cited, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (3)
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_j)
estadd ysumm
outreg2 using $dir/reg_results/tableb18.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Cited, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (4)
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if ((allfemale_09_100_j==1)|(allmale_09_100_j==1)) & ((allfemale_09_100_i==1)|(allmale_09_100_i==1)), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_j)
estadd ysumm
outreg2 using $dir/reg_results/tableb18.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Cited, Sample, Homo Gender) addstat(Mean of dependent variable, e(ymean))

* Col (5)
reghdfe omission leadfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_j)
estadd ysumm
outreg2 using $dir/reg_results/tableb18.doc, append dec(4) keep(leadfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Cited, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (6)
reghdfe omission leadfemale_09_100_j leadfemale_09_100_i leadfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_j)
estadd ysumm
outreg2 using $dir/reg_results/tableb18.doc, append dec(4) keep(leadfemale_09_100_j leadfemale_09_100_i leadfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Cited, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (7)
reghdfe omission allfemale_09_100_j leadfemale_09_100_i allfemale_leadfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_j)
estadd ysumm
outreg2 using $dir/reg_results/tableb18.doc, append dec(4) keep(allfemale_09_100_j leadfemale_09_100_i allfemale_leadfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Cited, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (8)
reghdfe omission allfemale_09_100_i leadfemale_09_100_j leadfemale_allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_j)
estadd ysumm
outreg2 using $dir/reg_results/tableb18.doc, append dec(4) keep(allfemale_09_100_i leadfemale_09_100_j leadfemale_allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Cited, Sample, All) addstat(Mean of dependent variable, e(ymean))



*** ============================================================================================================
*** Table B19. Exist_Female instead of Lead_Female in Gender Interaction Effects
*** LPM, gender only (with interactions), no race, 1980-2015, KPSS firms
*** ============================================================================================================
* Col (1)
reghdfe omission allfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb19.doc, replace dec(4) keep(allfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (2)
reghdfe omission allfemale_09_100_i sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb19.doc, append dec(4) keep(allfemale_09_100_i sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (3)
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb19.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (4)
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if ((allfemale_09_100_j==1)|(allmale_09_100_j==1)) & ((allfemale_09_100_i==1)|(allmale_09_100_i==1)), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb19.doc, append dec(4) keep(allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, Homo Gender) addstat(Mean of dependent variable, e(ymean))

* Col (5)
reghdfe omission existfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb19.doc, append dec(4) keep(existfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (6)
reghdfe omission existfemale_09_100_j existfemale_09_100_i existfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb19.doc, append dec(4) keep(existfemale_09_100_j existfemale_09_100_i existfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (7)
reghdfe omission allfemale_09_100_j existfemale_09_100_i allfemale_existfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb19.doc, append dec(4) keep(allfemale_09_100_j existfemale_09_100_i allfemale_existfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))

* Col (8)
reghdfe omission allfemale_09_100_i existfemale_09_100_j existfemale_allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb19.doc, append dec(4) keep(allfemale_09_100_i existfemale_09_100_j existfemale_allfemale_09_100_ji sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, Yes, Firm j FE, Yes, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All) addstat(Mean of dependent variable, e(ymean))



*** ============================================================================================================
*** Table B20. Rare Events Logit (Benchmark regression)
*** RE Logit, gender only (no interaction), no race, 1980-2015, KPSS firms
*** ============================================================================================================
* RE Logit doesn't accept i.var. Manually encode
gen main_cpc_i_A = (main_cpc_section_i == "A")
gen main_cpc_i_B = (main_cpc_section_i == "B")
gen main_cpc_i_C = (main_cpc_section_i == "C")
gen main_cpc_i_D = (main_cpc_section_i == "D")
gen main_cpc_i_E = (main_cpc_section_i == "E")
gen main_cpc_i_F = (main_cpc_section_i == "F")
gen main_cpc_i_G = (main_cpc_section_i == "G")
gen main_cpc_i_H = (main_cpc_section_i == "H")

gen main_cpc_j_A = (main_cpc_section_j == "A")
gen main_cpc_j_B = (main_cpc_section_j == "B")
gen main_cpc_j_C = (main_cpc_section_j == "C")
gen main_cpc_j_D = (main_cpc_section_j == "D")
gen main_cpc_j_E = (main_cpc_section_j == "E")
gen main_cpc_j_F = (main_cpc_section_j == "F")
gen main_cpc_j_G = (main_cpc_section_j == "G")
gen main_cpc_j_H = (main_cpc_section_j == "H")

forval year = 1982/2015 {
    gen year`year' = (patent_year_i == `year')
}

* Col (1)
relogit omission allfemale_09_100_j, cluster(patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb20.doc, replace dec(4) e(r2_p) keep(allfemale_09_100_j) addtext(Firm i FE, No, Firm j FE, No, Year i FE, No, Main CPC Section i FE, No, Main CPC Section j FE, No, Cluster SE, Citing, Sample, All, Spec, RELogit) addstat(Mean of dependent variable, e(ymean))

* Col (2)
relogit omission allfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, cluster(patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb20.doc, append dec(4) e(r2_p) keep(allfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, No, Firm j FE, No, Year i FE, No, Main CPC Section i FE, No, Main CPC Section j FE, No, Cluster SE, Citing, Sample, All, Spec, RELogit) addstat(Mean of dependent variable, e(ymean))

* Col (3) 
relogit omission allfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag year1983 year1984 year1985 year1986 year1987 year1988 year1989 year1990 year1991 year1992 year1993 year1994 year1995 year1996 year1997 year1998 year1999 year2000 year2001 year2002 year2003 year2004 year2005 year2006 year2007 year2008 year2009 year2010 year2011 year2012 year2013 year2014 year2015 main_cpc_i_A main_cpc_i_B main_cpc_i_C main_cpc_i_D main_cpc_i_E main_cpc_i_F main_cpc_i_G main_cpc_j_A main_cpc_j_B main_cpc_j_C main_cpc_j_D main_cpc_j_E main_cpc_j_F main_cpc_j_G, cluster(patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb20.doc, append dec(4) e(r2_p) keep(allfemale_09_100_j sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, No, Firm j FE, No, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All, Spec, RELogit) addstat(Mean of dependent variable, e(ymean))

* Col (4)
gen cited_allmale = (genderdiscrete_09_100_j == "allmale")
gen cited_allfemale = (genderdiscrete_09_100_j == "allfemale")
gen cited_mixed = (genderdiscrete_09_100_j == "mixed")
gen cited_undetermined = (genderdiscrete_09_100_j == "undetermined")

relogit omission cited_allfemale cited_mixed cited_undetermined sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag year1983 year1984 year1985 year1986 year1987 year1988 year1989 year1990 year1991 year1992 year1993 year1994 year1995 year1996 year1997 year1998 year1999 year2000 year2001 year2002 year2003 year2004 year2005 year2006 year2007 year2008 year2009 year2010 year2011 year2012 year2013 year2014 year2015 main_cpc_i_A main_cpc_i_B main_cpc_i_C main_cpc_i_D main_cpc_i_E main_cpc_i_F main_cpc_i_G main_cpc_j_A main_cpc_j_B main_cpc_j_C main_cpc_j_D main_cpc_j_E main_cpc_j_F main_cpc_j_G, cluster(patent_id_i)
estadd ysumm
outreg2 using $dir/reg_results/tableb20.doc, append dec(4) e(r2_p) keep(cited_allfemale cited_mixed cited_undetermined sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag) addtext(Firm i FE, No, Firm j FE, No, Year i FE, Yes, Main CPC Section i FE, Yes, Main CPC Section j FE, Yes, Cluster SE, Citing, Sample, All, Spec, RELogit) addstat(Mean of dependent variable, e(ymean))


*** ============================================================================================================
*** Table B21. Omission and Future Productivity log(1+x)
*** See above (right after Table 5)
*** ============================================================================================================


*** ============================================================================================================
*** Table B22. Robustness Check: No Self-Citation
*** See run_reg_noselfcite.do
*** ============================================================================================================


*** ============================================================================================================
*** Table B23. Robustness Check: Double/Debiased Machine Learning
*** See gender_doubleml folder
*** Run doubleml_gender.py
*** ============================================================================================================


*** ================================================================================================================
*** Figure 1. Network Effects (Distance between lead inventors). Include mixed-gender
*** LPM, gender interactions, 1981-2015, KPSS firms.
*** ================================================================================================================
* node_dist_first (i.e. distance between lead inventors)
forvalues i = 2/7 {
	gen allfemalej_binned_first`i' = allfemale_09_100_j * (binned_node_dist_first == `i')
}

reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji ib1.binned_node_dist_first allfemalej_binned_first2 allfemalej_binned_first3 allfemalej_binned_first4 allfemalej_binned_first5 allfemalej_binned_first6 allfemalej_binned_first7 sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
matrix list e(V)
* I use Python to generate the final plot, based on coefficient outputs. See summary_stat_plot.ipynb


*** ================================================================================================================
*** Figure B1. Network Effects (Distance between lead inventors). No mixed-gender.
*** LPM, gender interactions, 1981-2015, KPSS firms.
*** ================================================================================================================
reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji ib1.binned_node_dist_first allfemalej_binned_first2 allfemalej_binned_first3 allfemalej_binned_first4 allfemalej_binned_first5 allfemalej_binned_first6 allfemalej_binned_first7 sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag if ((allfemale_09_100_j==1)|(allmale_09_100_j==1)) & ((allfemale_09_100_i==1)|(allmale_09_100_i==1)), absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
matrix list e(V)


*** ================================================================================================================
*** Figure B2. Network Effects (Distance between closest inventors). Include mixed-gender.
*** LPM, gender interactions, 1980-2015, KPSS firms.
*** ================================================================================================================
* node_dist_all (i.e. distance between closest inventors)
forvalues i = 2/7 {
	gen allfemalej_binned_all`i' = allfemale_09_100_j * (binned_node_dist_all == `i')
}

reghdfe omission allfemale_09_100_j allfemale_09_100_i allfemale_09_100_ji ib1.binned_node_dist_all allfemalej_binned_all2 allfemalej_binned_all3 allfemalej_binned_all4 allfemalej_binned_all5 allfemalej_binned_all6 allfemalej_binned_all7 sim_score dollar_real_log_j num_citations_i num_inventors_i num_inventors_j avg_experience_i avg_experience_j same_main_cpc same_assignee_country years_lag, absorb(assignee_id_i_enc assignee_id_j_enc patent_year_i main_cpc_section_i_enc main_cpc_section_j_enc) vce(cluster patent_id_i)
matrix list e(V)


